
/**
*This software is under LGPL license,
*see http://www.gnu.org/licenses/lgpl-3.0.txt (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>)
*Console.h First issued by chuanshenglu@gmail.com 2008.10
*/

#ifndef __TRSESSION_H__
#define __TRSESSION_H__

#include "trstd.h"
#include "TRSession.h"
#include "Listener.h"
#include "Console.h"

namespace TR{
	//TRSession actually does all the heavy work background;
	class TRSession
		:public IKeyboardEventListener,
		public IFocusEventListener
	{
	public:
		//There're two working mode here
		typedef enum{
			COMMAND,
			EDIT
		}SessionMode;
	private:
		TRSession();
	protected:
		Console*	mConsole;
		SessionMode mMode;
		String		mCommandBuf;

		void ParseAndExec();
	public:
		TRSession(Console&);
		TRSession(TRSession&);
		virtual ~TRSession();

		//Message processing handling
		virtual void OnKeyDown(KeyboardEvent&);
		//virtual void OnkeyUp(KeyboardEvent&);

		virtual void ExecuteCommand();
	};
}

#endif